<!--海外仓收货任务-->
<template>
  <div class="page-container">
    <page_breadcrumb
      :getKeyMethod="init_table_model"
      @change="change_table_model"
    />
    <ex_super_table_page
      v-bind="option"
      ref="SuperTablePage"
      
    >
    </ex_super_table_page>

    <!-- <detail_overseas_inbound ref="detail_overseas_inbound" /> -->
    <overseas_quickReceiving
      ref="overseas_quickReceiving"
      @submitSuccess="submitQuickTackDelivery"
      :tableModel="[
        {
          key: 'inboundOrderCode',
          label: 'label_inbound_code',
          'min-width': 140,
          'show-overflow-tooltip': true,
        },
        {
          key: 'code',
          label: 'label_receiving_code',
          'min-width': 120,
          'show-overflow-tooltip': true,
        },
        {
          key: 'customerCode',
          label: 'label_customer_info',
          width: 120,
          'show-overflow-tooltip': true,
        },
        {
          key: 'expectBoxQty',
          label: 'label_plan_inbound_sku_count',
          width: 100,
        },
        {
          key: 'expectSkuQty',
          label: 'label_plan_inbound_sku_count',
          width: 100,
        },
        {
          key: 'expectBoxQty',
          label: 'label_actual_inbound_box_count',
          width: 100,
        },
        {
          key: 'expectSkuQty',
          label: 'label_actual_inbound_sku_count',
          width: 100,
        },
      ]"
      orderKeyId="inboundOrderId"
    />

  
  </div>
</template>
<script>
import superTablePageFunction from "@/mixin/super-table-page-function";
// import detail_overseas_inbound from "./dialog/detail_overseas_inbound.vue";
import overseas_quickReceiving from "./dialog/overseas_quickReceiving.vue";

import page_table_model_manage from "@/mixin/page_table_model_manage";
import emitOnFunction from "@/mixin/emit-on-function";
const emitKey = "overseas=>receiving_task";
export default {
  title: "title_standard_receiving_task",
  mixins: [
    superTablePageFunction,
    emitOnFunction(emitKey),
    page_table_model_manage,
  ],
  components: {

    overseas_quickReceiving,
  },
  data() {
    return {
      option: {
        search: {
          model: [
            { label: "label_receiving_code", key: "receivingCode" },
            { label: "label_inbound_code", key: "inboundOrderCode" },
            {
              label: "label_receiving_status",
              key: "receivingStatus",
              type: "select",
              enum: "ReceivingTaskStatusEnum",
            },
            { label: "label_sku", key: "skuId", type: 'sku_selec_input', fold: true, },
           
            {
              label: "label_create_time", key: 'startCreateDate', fold: true,type: 'date-picker',attrs:{type: 'datetime'},
              render: (h, { data, item }) => {
                const value = data[item.key]
                const limitKey = 'endCreateDate'
                const limitValue = data[limitKey]

                return (<ex_super_input value={value} onInput={e => this.$set(data, item.key, e)} type="date-picker" placeholder="label_start_time"
                  attrs={{ type: 'datetime' }}
                  pickerOptions={{
                    disabledDate: date => { return limitValue ? (limitValue < date.getTime()) : false }
                  }}
                />)
              }

            },
            {
              label: "~", key: 'endCreateDate', fold: true,type: 'date-picker',attrs:{type: 'datetime'},
              render: (h, { data, item }) => {
                const value = data[item.key]
                const limitKey = 'startCreateDate'
                const limitValue = data[limitKey]
                return (<ex_super_input value={value} onInput={e => this.$set(data, item.key, e)} type="date-picker" placeholder="label_end_time"
                  attrs={{ type: 'datetime' ,'default-time': '23:59:59'}}
                  pickerOptions={{
                    disabledDate: date => { return limitValue ? (limitValue > date.getTime()) : false }
                  }}
                />)
              }
            },
            {
              label: "label_tms_complete_date", key: 'startFinishDate', fold: true,type: 'date-picker',attrs:{type: 'datetime'},
              render: (h, { data, item }) => {
                const value = data[item.key]
                const limitKey = 'endFinishDate'
                const limitValue = data[limitKey]

                return (<ex_super_input value={value} onInput={e => this.$set(data, item.key, e)} type="date-picker" placeholder="label_start_time"
                  attrs={{ type: 'datetime' }}
                  pickerOptions={{
                    disabledDate: date => { return limitValue ? (limitValue < date.getTime()) : false }
                  }}
                />)
              }

            },
            {
              label: "~", key: 'endFinishDate', fold: true,type: 'date-picker',attrs:{type: 'datetime'},
              render: (h, { data, item }) => {
                const value = data[item.key]
                const limitKey = 'startFinishDate'
                const limitValue = data[limitKey]
                return (<ex_super_input value={value} onInput={e => this.$set(data, item.key, e)} type="date-picker" placeholder="label_end_time"
                  attrs={{ type: 'datetime' ,'default-time': '23:59:59'}}
                  pickerOptions={{
                    disabledDate: date => { return limitValue ? (limitValue > date.getTime()) : false }
                  }}
                />)
              }
            },
          ],
        },
        actionExtra: [
    
          {
            label: "label_new_check",auth:'/page/wms/overseas/inbound/check',
            attrs: { type: "primary" },
            click: this.gotoCheck,
          },
          // { label: "label_export", click: this.$noFunction },
        ],
        table: {
          url: "/wms-api/inbound/WmsInboundOverseasReceivingRpc/selectPage.json",
          model: this.init_table_model(),
        },
      },
    };
  },

  methods: {
    option_table_model() {
      return [
        { type: "selection", clickToggle: true },
        {
          key: "code",
          label: "label_receiving_code",
          "min-width": 120,
          "show-overflow-tooltip": true,
        },
        {
          key: "inboundOrderCode",
          label: "label_inbound_code",
          "min-width": 120,
          "show-overflow-tooltip": true,
        },
        // { key: 'customerName', label: 'label_customer_info', },
        { key: "expectBoxQty", label: "label_expected_box_number", width: 120 },
        { key: "expectSkuQty", label: "label_expected_sku_number", width: 120 },
        {
          key: "receivingBoxQty",
          label: "label_receiving_box_number",
          width: 120,
        },
        { key: "receivingSkuQty", label: "label_receiving_number", width: 120 },
        {
          key: "receivingStatus",
          label: "label_receiving_status",
          "show-overflow-tooltip": true,
          width: 120,
          formatter: (r, c, v, i) =>
            this.$enumShow(v, "ReceivingTaskStatusEnum"),
        },
        {
          key: "receivingTime",
          label: "label_receiving_time",
          width: 130,
          formatter: (r, c, v, i) => this.$dateFormat(v),
        },

        {
          key: "receivingUserName",
          label: "label_receiving_user",
          width: 120,
          "show-overflow-tooltip": true,
        },
        {
          key: "modifier",
          label: "label_audit_user",
          width: 120,
          "show-overflow-tooltip": true,
        },

        {
          type: "operate",
          width: 160,
          operate: [
            {
              type: "more",
              items: [
                {
                  label: "label_view_detail",
                  click: (row) => {
                    this.clickDetail(row);
                  },
                },
                {
                  label: "label_receiving",auth:'/page/wms/overseas/inbound/receiving',
                  click: (row) => {
                    this.gotoReceiving(row);
                  },
                },
                {
                  label: "label_acceptance",auth:'/page/wms/overseas/inbound/check',
                  click: (row) => this.gotoCheck(row),
                },
                {
                  label: "label_putaway",auth:'/page/wms/overseas/inbound/putaway',
                  click: (row) => {
                    this.gotoPutaway(row);
                  },
                },
                  {
                  label: "label_receiving_confirm",auth:'wms_overseas_receiving_confirm',
                  click: (row) => this.receivingConfirm(row),
                },
                {
                  label: "label_reset_receiving",auth:'wms_overseas_reset_receiving',
                  click: (row) => this.resetReceiving(row),
                },
              
              ],
            },
          ],
        },
      ];
    },
    gotoCheck(row) {
      let query = {};
      if (row) {
        query = { inboundOrderCode: row.inboundOrderCode };
      }
      this.$router.push({
        name: "/page/wms/overseas/inbound/check",
        params: query,
      });
    },
    gotoPutaway(row) {
      this.$router.push({
        name: "/page/wms/overseas/inbound/putaway",
        params: { inboundOrderCode: row.inboundOrderCode },
      });
    },
    gotoReceiving(row) {
      this.$router.push({
        name: "/page/wms/overseas/inbound/receiving",
        params: { receivingCode: row.code },
      });
    },

    clickDetail(row) {
      // let title = `${this.$tt("label_receiving_code")}:${row.code}/${this.$tt(
      //   "label_inbound_code"
      // )}:${row.inboundOrderCode}`;
      // this.$refs["detail_overseas_inbound"].show({
      //   params: { id: row.inboundOrderId },
      //   title,
      // });

      this.$router.push({ name: '/page/wms/overseas/inbound/inbound_detail', query: { 'id': row.inboundOrderId } })
    },
    receivingConfirm(row) {
      this.$confirm(
        this.$tt("text_is_sure_receiving_confirm"),
        this.$tt("label_tip"),
        {
          type: "warning",
        }
      )
        .then(() => {
          this.$ajax({
            url: "/wms-api/inbound/WmsInboundOverseasInboundOrderRpc/receivingConfirm.json",
            method: "post",
            type: "json",
            data: { inboundOrderId: row.inboundOrderId },
            success: (res) => {
              this.$message.success(this.$tt("tip_submit_success"));
              this.reload();
            },
          });
        })
        .catch(() => {});
    },
    resetReceiving(row) {
      this.$confirm(
        this.$tt("text_is_sure_reset_receiving"),
        this.$tt("label_tip"),
        {
          type: "warning",
        }
      )
        .then(() => {
          this.$ajax({
            url: "/wms-api/inbound/WmsInboundOverseasInboundOrderRpc/resetReceiving.json",
            method: "post",
            type: "json",
            data: { inboundOrderId: row.inboundOrderId },
            success: (res) => {
              this.$message.success(this.$tt("tip_submit_success"));
              this.reload();
              this.$emitPage("standard>inbound_manage", "reload");
            },
          });
        })
        .catch(() => {});
    },
    clickQuickReceiving() {
      let _list = this.getSelection();
      if (_list.length <= 0) {
        return this.$message.error(this.$tt("tip_noSelect_receiving_list"));
      }
      // if (_list.some(it => !['WAIT_INBOUND', 'WAIT_RECEIVING', 'WAIT_PUTAWAY'].some(e => e == it.status))) {
      //   return this.$message.error(this.$tt('tip_status_error_no_operate'))
      // }
      this.$refs.overseas_quickReceiving.show({
        tableList: _.cloneDeep(_list),
      });
    },
    submitQuickTackDelivery() {
      this.reload();
    },
  },
};
</script>
<style></style>
